package com.example.administrator.myapplication.util;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2020/12/17.
 */

public class GetJsonDataUtil {

    public String getJson(Context context,String fileName){
        StringBuilder stringBuilder= new StringBuilder();


        try {
            AssetManager assetManager= context.getAssets();
            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(assetManager.open(fileName)));
        String str ="";
            while ((str=bufferedReader.readLine())!=null){
                stringBuilder.append(str);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return stringBuilder.toString();
    }
}
